const state = {
    openJudge: false,
    labelList: [],
    //上一个路由
    oldRouterPath:'',
    //权限修改角色ID
    roleIdAuto:null,
    //权限的页面改变
    authorityJudge:'rolesex',
    //菜单的展开行
    defaultActive:'x',
}

const mutations = {
    BOOLCHANGE: (state) => {
        state.openJudge = !state.openJudge
    },
    ADDLABELLIST: (state, msg) => {
        state.oldRouterPath  = msg.menuName;
        if (state.labelList.length > 10) {
            state.labelList.splice(0, 1);
        }
        var hasJ = true;
        for (let i in state.labelList) {
            if (state.labelList[i].menuName == msg.menuName) {
                hasJ = false;
            }
        }
        if(hasJ){
            state.labelList.push(msg);
        }

    },
    DELETELABELLIST: (state, name) => {
        for (let i in state.labelList) {
            if (state.labelList[i].menuName == name) {
                state.labelList.splice(i, 1);
            }
        }
    },
    ROLEIDAUTOUPDATE: (state, id) => {
        state.roleIdAuto = id
    },
    AUTOUPJUDGE: (state, valueh) => {
        state.authorityJudge = valueh
    },
    FLUSHLISH : (state) => {
        state.labelList = []
    },
    CHANFEDEFAULTACTIVE : (state , activeData) => {
        state.defaultActive = activeData
    },


}
const getters = {
    GETDEFAULTACTIVE : state => {
        return state.defaultActive;
    },
    GETLABLELIST : state =>{
        return state.oldRouterPath;
    },
    GETROLEIDAUTO :  state => {
        return state.roleIdAuto;
    },
    GETAUTOUPJUDGE :  state => {
        return state.authorityJudge;
    },
}
const actions = {}

export default {
    namespaced: true,
    state,
    mutations,
    getters,
    actions
}